/*
 * salaBus.cpp
 *
 */

#include <sstream>
#include <iostream>
#include <cstdlib>
#include "Argv.h"
#include "StringUtils.h"
#include "ProcessAux.h"
#include "Middleware/IPCCommunicationService.h"
#include "Middleware/MiddlewareMessages.h"
#include <exception>
#include "logger/logger.h"
#include "API/SalaBus.h"


int main(int argc, char **argv)
{
    Argv arguments;
    SalaId salaId;
    BusId busId;

    arguments.setArgv(argv);

    salaId = StringUtils::StringToNumber<int>(arguments.getArg(1));
    busId = (salaId+1)/2;

    std::stringstream ss;
    ss<<"Sala Bus "<< salaId;

	CLogger::create(ss.str());
	CLogger::setLevel(LogLevelEnum::DEBUG);

	try{

		API::SalaBus sala(API::SalaBus::ATENDER_PERSONAS);

		ss.str("");
		ss<<"Sala Bus with bus:"<< busId;
		CLogger::log(ss.str(),LogLevelEnum::INFO);

		sala.run(salaId,busId);

		CLogger::log("Sala Bus ended.",LogLevelEnum::INFO);
	}
	catch (std::exception &e)
	{
		CLogger::log(e.what(),LogLevelEnum::FATAL);
	}
	return 0;
}
